// 定义粒子的接口
interface ParticlesConfig {
    // 背景配置
    background: {
        color: {
            value: string; // 背景颜色值
        };
    };
    // 帧率限制
    fpsLimit: number; // 每秒帧数限制

    // 交互性配置
    interactivity: {
        events: {
            onClick: {
                enable: boolean; // 是否启用点击事件
                mode: string; // 点击事件的模式
            };
            onHover: {
                enable: boolean; // 是否启用悬停事件
                mode: string; // 悬停事件的模式
            };
            resize: boolean; // 是否在窗口大小调整时重新计算粒子位置
        };
        modes: {
            bubble: {
                distance: number; // 冲突距离
                duration: number; // 动画持续时间
                opacity: number; // 不透明度
                size: number; // 粒子大小
            };
            push: {
                quantity: number; // 推动的粒子数量
            };
            repulse: {
                distance: number; // 排斥距离
                duration: number; // 动画持续时间
            };
        };
    };

    // 粒子配置
    particles: {
        color: {
            value: string; // 粒子颜色值
        };
        links: {
            color: string; // 粒子间连线颜色
            distance: number; // 粒子间连线距离
            enable: boolean; // 是否启用粒子间连线
            opacity: number; // 粒子间连线不透明度
            width: number; // 粒子间连线宽度
        };
        move: {
            direction: string; // 粒子移动方向
            enable: boolean; // 是否启用粒子移动
            outMode: string; // 粒子离开画布的模式
            random: boolean; // 粒子移动是否随机
            speed: number; // 粒子移动速度
            straight: boolean; // 粒子移动是否沿直线
        };
        number: {
            density: {
                enable: boolean; // 是否启用粒子密度控制
                area?: number; // 粒子密度区域（可选字段）
            };
            value: number; // 粒子数量
        };
        opacity: {
            value: number; // 粒子不透明度
        };
        shape: {
            type: string; // 粒子形状类型
        };
        size: {
            random?: boolean; // 粒子大小是否随机（可选字段）
            value: number | { min: number; max: number }; // 粒子大小值或大小范围
        };
    };

    // 是否检测视网膜屏幕
    detectRetina: boolean; // 如果为true，则根据设备的像素比调整粒子的尺寸
}
const particlesConfig: ParticlesConfig = {
    background: {
        color: {
            value: "black",
        },
    },
    fpsLimit: 120,
    interactivity: {
        events: {
            onClick: {
                enable: true,
                mode: "push",
            },
            onHover: {
                enable: true,
                mode: "repulse",
            },
            resize: true,
        },
        modes: {
            bubble: {
                distance: 400,
                duration: 2,
                opacity: 0.8,
                size: 40,
            },
            push: {
                quantity: 4,
            },
            repulse: {
                distance: 200,
                duration: 0.4,
            },
        },
    },
    particles: {
        color: {
            value: "random",
        },
        links: {
            color: "random",
            distance: 150,
            enable: true,
            opacity: 0.5,
            width: 1,
        },
        move: {
            direction: "none",
            enable: true,
            outMode: "bounce",
            random: false,
            speed: 6,
            straight: false,
        },
        number: {
            density: {
                enable: true,
            },
            value: 80,
        },
        opacity: {
            value: 0.5,
        },
        shape: {
            type: "circle",
        },
        size: {
            value: { min: 1, max: 5 },
        },
    },
    detectRetina: true,
};

const particlesConfig2: ParticlesConfig = {
    background: {
        color: {
            value: "black",
        },
    },
    fpsLimit: 120,
    interactivity: {
        events: {
            onClick: {
                enable: true,
                mode: "push",
            },
            onHover: {
                enable: true,
                mode: "repulse",
            },
            resize: true,
        },
        modes: {
            bubble: {
                distance: 400,
                duration: 2,
                opacity: 0.8,
                size: 20,
            },
            push: {
                quantity: 4,
            },
            repulse: {
                distance: 200,
                duration: 0.4,
            },
        },
    },
    particles: {
        color: {
            value: "#ffffff",
        },
        links: {
            color: "#ffffff",
            distance: 150,
            enable: true,
            opacity: 0.5,
            width: 1,
        },
        move: {
            direction: "none",
            enable: true,
            outMode: "bounce",
            random: false,
            speed: 6,
            straight: false,
        },
        number: {
            density: {
                enable: true,
                area: 800,
            },
            value: 120,
        },
        opacity: {
            value: 0.5,
        },
        shape: {
            type: "circle",
        },
        size: {
            random: true,
            value: 3,
        },
    },
    detectRetina: true,
};

function getRandomParticlesConfig(): ParticlesConfig {
    const randomNum = Math.random();
    return randomNum < 0.5 ? particlesConfig : particlesConfig2;
}
export default getRandomParticlesConfig();